<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <title>layedit</title>
  <link rel="stylesheet" href="static/layui-v2.5.6/layui/css/layui.css" media="all">
</head>
<body>
	<form class="layui-form" lay-filter="formLayedit" action="admin.html">
		<div class="layui-form-item">
			<label class="layui-form-label">选择框</label>
			<div class="layui-input-block">
			   <textarea name="layedit" id="layedit" style="display: none;"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
		  <div class="layui-input-block">
			<button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">登录</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		  </div>
		</div>
	</form>
	
<script src="static/layui-v2.5.6/layui/layui.js"></script>
<script>
layui.use(['form',"jquery","layedit"], function(){
    var $ = layui.jquery
		,layedit = layui.layedit
		,form = layui.form;
	//
	layedit.set({
		//暴露layupload参数设置接口 --详细查看layupload参数说明
		uploadImage: {
			url: 'your url',
			field: 'file',//上传时的文件参数字段名
			accept: 'image',
			acceptMime: 'image/*',
			exts: 'jpg|png|gif|bmp|jpeg',
			size: 1024 * 10,
			done: function (data) {//文件上传接口返回code为0时的回调
			}
		}
		, uploadVideo: {
			url: 'your url',
			field: 'file',//上传时的文件参数字段名
			accept: 'video',
			acceptMime: 'video/*',
			exts: 'mp4|flv|avi|rm|rmvb',
			size: 1024 * 2 * 10,
			done: function (data) {//文件上传接口返回code为0时的回调
			}
		}
		//右键删除图片/视频时的回调参数，post到后台删除服务器文件等操作，
		//传递参数：
		//图片： imgpath --图片路径
		//视频： filepath --视频路径 imgpath --封面路径
		, calldel: {
			url: 'your url',
			done: function (data) {//data删除文件接口返回返回的数据
			}
		}
		//开发者模式 --默认为false
		, devmode: true
		 , fontFomatt:["p","span"]  //自定义段落格式 ，如不填，默认为 ["p", "h1", "h2", "h3", "h4", "h5", "h6", "div"]~~
		 , tool: [
			 'html','undo','redo','code'
			, 'strong', 'italic', 'underline', 'del', 
			,'addhr' //添加水平线
			,'|', 'fontFomatt','colorpicker' //段落格式，字体颜色
			, 'face', '|', 'left', 'center', 'right', '|', 'link', 'unlink'
			, 'image_alt', 'altEdit', 'video' 
			,'anchors' //锚点
			 , '|'
			 , 'table'//插入表格
			 ,'customlink'//插入自定义链接
			 ,'fullScreen'
		 ]
 });
 //
    layedit.build('layedit',{
		tool: ['left', 'center', 'right','image','images'],
		uploadImage: {
			url: 'http://192.168.26.7/api/uploadLayedit'
			,type: 'post'
		}
	});
	
	var ieditor = layedit.build('layedit');
	layedit.setContent(ieditor,"hello layedit",false);
	
	form.val('formLayedit',{
		layedit:'点击按钮设置的内容：<span style="color: #e03e2d;">' + new Date()+'</span>'
	})
	
	form.on('submit(formDemo)', function(data){
	  layer.msg(JSON.stringify(data.field));
	  var content = tinymce.get('#file').getContent()
	  layer.alert(content)
	  return false;
	});
});
</script>
</body>
</html>